﻿using System.Web;

namespace Sex
{
    public partial class Sex : System.Web.UI.Page
    {
        class ListCookies : MyList
        {
            string GetCookieProperties(System.Web.HttpCookie c)
            {
                string result = "";
                result += FormatMyKey("Domain") + FormatMyText("=") + c.Domain + "<br/>";
                result += FormatMyKey("Expires") + FormatMyText("=") + c.Expires + "<br/>";
                result += FormatMyKey("HttpOnly") + FormatMyText("=") + c.HttpOnly + "<br/>";
                result += FormatMyKey("HasKeys") + FormatMyText("=") + c.HasKeys + "<br/>";
                result += FormatMyKey("Name") + FormatMyText("=") + c.Name + "<br/>";
                result += FormatMyKey("Path") + FormatMyText("=") + c.Path + "<br/>";
                result += FormatMyKey("Secure") + FormatMyText("=") + c.Secure + "<br/>";
                result += FormatMyKey("Value") + FormatMyText("=") + Untag(c.Value) + "<br/>";
                return result;
            }
            public ListCookies(State MyState)
                : base(MyState, "Cookies Object")
            {
                HttpContext myHttpContext = HttpContext.Current;
                HttpCookie MyCookie = new HttpCookie(strDemoVariableName, strDemoEntry);
                myHttpContext.Response.Cookies.Add(MyCookie);
                int c = 0;
                AddTitle("Request-Cookies", 2);
                for (int i = 0; i < myHttpContext.Request.Cookies.Count; i++)
                {
                    Add("Request" + c.ToString().PadLeft(2,'0') + ":" + myHttpContext.Request.Cookies[i].Name, GetCookieProperties(myHttpContext.Request.Cookies[i]));
                    c++;
                }
                c = 0;
                AddTitle("Response-Cookies", 2);
                for (int i = 0; i < myHttpContext.Response.Cookies.Count; i++)
                {
                    Add("Response" + c.ToString().PadLeft(2, '0') + ":" + myHttpContext.Response.Cookies[i].Name, GetCookieProperties(myHttpContext.Response.Cookies[i]));
                    c++;
                }
            }
        }
    }
}